//连接数据库
var mysql = require('mysql');
var connection = mysql.createConnection({
    host: 'localhost',
    user: 'stock',
    password: 'stockjj',
    database:'test'
});

connection.connect();
//查询
connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
    if (err) throw err;
    console.log('The solution is: ', rows[0].solution);
});

//查询
connection.query('SELECT * FROM `users`', function(err, rows, fields) {
    if (err) throw err;
    console.log('The users are: ', rows[0]);
});
//关闭连接
connection.end();